Docker Set up on centos 8
· 2 min read
We are going to install docker CE in centos 8. Here I am not going to explain what is docker and what the image. We will have another chapter. Only Script with steps by steps and some experienced issues during set up.
Recommended approach,
- Set up Docker repositories in your VM
- Install from repositories
- Upgrde from repositories
#
Install the yum-utils packagesudo yum install -y yum-utilssudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
#
Install Dockersudo yum install -y docker-ce docker-ce-cli containerd.io
#
Start/Eanble Docker Servicesudo systemctl enable dockersudo systemctl start docker
#
Verify Docker Servicesudo docker run hello-world
#
Rootless Mode changeRootless mode allows running the Docker daemon and containers as a non-root user to mitigate potential vulnerabilities in the daemon and the container runtime. Need to create Non-Root User otherwsie you may encounter the follwing error
[ERROR] Refusing to install rootless Docker as the root user
useradd <USERNAME>passwd <YOUR_PASSWORD>
Switch to the created Non-Root User
id -uwhoamigrep ^$(whoami): /etc/subuidgrep ^$(whoami): /etc/subgid
Install specific required packages for centos 8
sudo yum install uidmapsudo dnf install -y fuse-overlayfssudo dnf install -y iptablessudo dnf install -y policycoreutils-python-utils && sudo semanage permissive -a iptables_t
cd /usr/bindockerd-rootless-setuptool.sh install
Now docker is configured as rootless mode.
[INFO] systemd not detected, dockerd-rootless.sh needs to be started manually:PATH=/usr/bin:/sbin:/usr/sbin:$PATH dockerd-rootless.sh[INFO] Creating CLI context "rootless"Successfully created context "rootless"[INFO] Make sure the following environment variables are set (or add them to ~/.bashrc):# WARNING: systemd not found. You have to remove XDG_RUNTIME_DIR manually on every logout.export XDG_RUNTIME_DIR=/home/appadmin/.docker/runexport PATH=/usr/bin:$PATHexport DOCKER_HOST=unix:///home/appadmin/.docker/run/docker.sock
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock
If you encounter the above error, we need to export
export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock
Regards